<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>QtWebApp: stefanfrings::TemplateCache Class Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">QtWebApp
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classstefanfrings_1_1TemplateCache.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#nested-classes">Classes</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pro-methods">Protected Member Functions</a> &#124;
<a href="classstefanfrings_1_1TemplateCache-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">stefanfrings::TemplateCache Class Reference</div>  </div>
</div><!--header-->
<div class="contents">

<p>Caching template loader, reduces the amount of I/O and improves performance on remote file systems.  
 <a href="classstefanfrings_1_1TemplateCache.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="templatecache_8h_source.html">templatecache.h</a>&gt;</code></p>
<div class="dynheader">
Inheritance diagram for stefanfrings::TemplateCache:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1TemplateCache__inherit__graph.png" border="0" usemap="#astefanfrings_1_1TemplateCache_inherit__map" alt="Inheritance graph"/></div>
<map name="astefanfrings_1_1TemplateCache_inherit__map" id="astefanfrings_1_1TemplateCache_inherit__map">
<area shape="rect" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems." alt="" coords="7,155,215,181"/>
<area shape="rect" href="classstefanfrings_1_1TemplateLoader.html" title="Loads localized versions of template files." alt="" coords="5,80,217,107"/>
<area shape="rect" title=" " alt="" coords="74,5,149,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<div class="dynheader">
Collaboration diagram for stefanfrings::TemplateCache:</div>
<div class="dyncontent">
<div class="center"><img src="classstefanfrings_1_1TemplateCache__coll__graph.png" border="0" usemap="#astefanfrings_1_1TemplateCache_coll__map" alt="Collaboration graph"/></div>
<map name="astefanfrings_1_1TemplateCache_coll__map" id="astefanfrings_1_1TemplateCache_coll__map">
<area shape="rect" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems." alt="" coords="7,155,215,181"/>
<area shape="rect" href="classstefanfrings_1_1TemplateLoader.html" title="Loads localized versions of template files." alt="" coords="5,80,217,107"/>
<area shape="rect" title=" " alt="" coords="74,5,149,32"/>
</map>
<center><span class="legend">[<a target="top" href="graph_legend.html">legend</a>]</span></center></div>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:aaac3a5eefcc6fad1e280e022ba87b6c3"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateCache.html#aaac3a5eefcc6fad1e280e022ba87b6c3">TemplateCache</a> (const QSettings *settings, QObject *parent=nullptr)</td></tr>
<tr class="memdesc:aaac3a5eefcc6fad1e280e022ba87b6c3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <a href="classstefanfrings_1_1TemplateCache.html#aaac3a5eefcc6fad1e280e022ba87b6c3">More...</a><br /></td></tr>
<tr class="separator:aaac3a5eefcc6fad1e280e022ba87b6c3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="inherit_header pub_methods_classstefanfrings_1_1TemplateLoader"><td colspan="2" onclick="javascript:toggleInherit('pub_methods_classstefanfrings_1_1TemplateLoader')"><img src="closed.png" alt="-"/>&#160;Public Member Functions inherited from <a class="el" href="classstefanfrings_1_1TemplateLoader.html">stefanfrings::TemplateLoader</a></td></tr>
<tr class="memitem:a25c1d61e6acd79e35feb71ac20751f30 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a25c1d61e6acd79e35feb71ac20751f30">TemplateLoader</a> (const QSettings *settings, QObject *parent=nullptr)</td></tr>
<tr class="memdesc:a25c1d61e6acd79e35feb71ac20751f30 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Constructor.  <a href="classstefanfrings_1_1TemplateLoader.html#a25c1d61e6acd79e35feb71ac20751f30">More...</a><br /></td></tr>
<tr class="separator:a25c1d61e6acd79e35feb71ac20751f30 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6914af0af09bc3f0e00f373c23e79382 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top"><a id="a6914af0af09bc3f0e00f373c23e79382"></a>
virtual&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a6914af0af09bc3f0e00f373c23e79382">~TemplateLoader</a> ()</td></tr>
<tr class="memdesc:a6914af0af09bc3f0e00f373c23e79382 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Destructor. <br /></td></tr>
<tr class="separator:a6914af0af09bc3f0e00f373c23e79382 inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a20a9bf4c48bd07fe1c358d02b09d408a inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top"><a class="el" href="classstefanfrings_1_1Template.html">Template</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a20a9bf4c48bd07fe1c358d02b09d408a">getTemplate</a> (const QString templateName, const QString locales=QString())</td></tr>
<tr class="memdesc:a20a9bf4c48bd07fe1c358d02b09d408a inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Get a template for a given locale.  <a href="classstefanfrings_1_1TemplateLoader.html#a20a9bf4c48bd07fe1c358d02b09d408a">More...</a><br /></td></tr>
<tr class="separator:a20a9bf4c48bd07fe1c358d02b09d408a inherit pub_methods_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-methods"></a>
Protected Member Functions</h2></td></tr>
<tr class="memitem:a82621fb5262920f2dd981c5f0047db51"><td class="memItemLeft" align="right" valign="top">virtual QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateCache.html#a82621fb5262920f2dd981c5f0047db51">tryFile</a> (const QString localizedName)</td></tr>
<tr class="memdesc:a82621fb5262920f2dd981c5f0047db51"><td class="mdescLeft">&#160;</td><td class="mdescRight">Try to get a file from cache or filesystem.  <a href="classstefanfrings_1_1TemplateCache.html#a82621fb5262920f2dd981c5f0047db51">More...</a><br /></td></tr>
<tr class="separator:a82621fb5262920f2dd981c5f0047db51"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="inherited"></a>
Additional Inherited Members</h2></td></tr>
<tr class="inherit_header pro_attribs_classstefanfrings_1_1TemplateLoader"><td colspan="2" onclick="javascript:toggleInherit('pro_attribs_classstefanfrings_1_1TemplateLoader')"><img src="closed.png" alt="-"/>&#160;Protected Attributes inherited from <a class="el" href="classstefanfrings_1_1TemplateLoader.html">stefanfrings::TemplateLoader</a></td></tr>
<tr class="memitem:aee91532454f736858307239c48c69523 inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top"><a id="aee91532454f736858307239c48c69523"></a>
QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#aee91532454f736858307239c48c69523">templatePath</a></td></tr>
<tr class="memdesc:aee91532454f736858307239c48c69523 inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Directory where the templates are searched. <br /></td></tr>
<tr class="separator:aee91532454f736858307239c48c69523 inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a08d5758493b8e26f42f72799fed1caac inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top"><a id="a08d5758493b8e26f42f72799fed1caac"></a>
QString&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a08d5758493b8e26f42f72799fed1caac">fileNameSuffix</a></td></tr>
<tr class="memdesc:a08d5758493b8e26f42f72799fed1caac inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Suffix to the filenames. <br /></td></tr>
<tr class="separator:a08d5758493b8e26f42f72799fed1caac inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2cb81190ac3993fda6e20e65713bfcce inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memItemLeft" align="right" valign="top"><a id="a2cb81190ac3993fda6e20e65713bfcce"></a>
QTextCodec *&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classstefanfrings_1_1TemplateLoader.html#a2cb81190ac3993fda6e20e65713bfcce">textCodec</a></td></tr>
<tr class="memdesc:a2cb81190ac3993fda6e20e65713bfcce inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="mdescLeft">&#160;</td><td class="mdescRight">Codec for decoding the files. <br /></td></tr>
<tr class="separator:a2cb81190ac3993fda6e20e65713bfcce inherit pro_attribs_classstefanfrings_1_1TemplateLoader"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Caching template loader, reduces the amount of I/O and improves performance on remote file systems. </p>
<p>The cache has a limited size, it prefers to keep the last recently used files. Optionally, the maximum time of cached entries can be defined to enforce a reload of the template file after a while. </p>
<p>In case of local file system, the use of this cache is optionally, since the operating system caches files already. </p>
<p>Loads localized versions of template files. If the caller requests a file with the name "index" and the suffix is ".tpl" and the requested locale is "de_DE, de, en-US", then files are searched in the following order:</p>
<ul>
<li>index-de_DE.tpl</li>
<li>index-de.tpl</li>
<li>index-en_US.tpl</li>
<li>index-en.tpl</li>
<li>index.tpl </li>
</ul>
<p>The following settings are required: <code></p><pre>
path=../templates
suffix=.tpl
encoding=UTF-8
cacheSize=1000000
cacheTime=60000
</pre><p></code> The path is relative to the directory of the config file. In case of windows, if the settings are in the registry, the path is relative to the current working directory. </p>
<p>Files are cached as long as possible, when cacheTime=0. </p><dl class="section see"><dt>See also</dt><dd><a class="el" href="classstefanfrings_1_1TemplateLoader.html" title="Loads localized versions of template files.">TemplateLoader</a> </dd></dl>

<p class="definition">Definition at line <a class="el" href="templatecache_8h_source.html#l00044">44</a> of file <a class="el" href="templatecache_8h_source.html">templatecache.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="aaac3a5eefcc6fad1e280e022ba87b6c3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aaac3a5eefcc6fad1e280e022ba87b6c3">&#9670;&nbsp;</a></span>TemplateCache()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">TemplateCache::TemplateCache </td>
          <td>(</td>
          <td class="paramtype">const QSettings *&#160;</td>
          <td class="paramname"><em>settings</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">QObject *&#160;</td>
          <td class="paramname"><em>parent</em> = <code>nullptr</code>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Constructor. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">settings</td><td>Configuration settings, usually stored in an INI file. Must not be 0. Settings are read from the current group, so the caller must have called settings-&gt;beginGroup(). Because the group must not change during runtime, it is recommended to provide a separate QSettings instance that is not used by other parts of the program. The <a class="el" href="classstefanfrings_1_1TemplateCache.html" title="Caching template loader, reduces the amount of I/O and improves performance on remote file systems.">TemplateCache</a> does not take over ownership of the QSettings instance, so the caller should destroy it during shutdown. </td></tr>
    <tr><td class="paramname">parent</td><td>Parent object </td></tr>
  </table>
  </dd>
</dl>

<p class="definition">Definition at line <a class="el" href="templatecache_8cpp_source.html#l00008">8</a> of file <a class="el" href="templatecache_8cpp_source.html">templatecache.cpp</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a82621fb5262920f2dd981c5f0047db51"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a82621fb5262920f2dd981c5f0047db51">&#9670;&nbsp;</a></span>tryFile()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">QString TemplateCache::tryFile </td>
          <td>(</td>
          <td class="paramtype">const QString&#160;</td>
          <td class="paramname"><em>localizedName</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">protected</span><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Try to get a file from cache or filesystem. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">localizedName</td><td>Name of the template with locale to find </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The template document, or empty string if not found </dd></dl>

<p>Reimplemented from <a class="el" href="classstefanfrings_1_1TemplateLoader.html#a4d63f9937e5f32de412f2b909eba7b4b">stefanfrings::TemplateLoader</a>.</p>

<p class="definition">Definition at line <a class="el" href="templatecache_8cpp_source.html#l00017">17</a> of file <a class="el" href="templatecache_8cpp_source.html">templatecache.cpp</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following files:<ul>
<li>templateengine/<a class="el" href="templatecache_8h_source.html">templatecache.h</a></li>
<li>templateengine/<a class="el" href="templatecache_8cpp_source.html">templatecache.cpp</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>stefanfrings</b></li><li class="navelem"><a class="el" href="classstefanfrings_1_1TemplateCache.html">TemplateCache</a></li>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
